﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Hack.Net.Downloader
{
    /// <summary>
    /// Provides data for the <see cref="FileDownloader.DownloadProgressChanged"/> event. 
    /// </summary>
    public class FileDownloadProgressChangedEventArgs : EventArgs
    {

        #region Fields
        private long bytesReceived;
        private long totalBytesToReceive;
        private int progressPercentage;
        #endregion

        #region Constructors
        internal FileDownloadProgressChangedEventArgs(long bytesReceived, long totalBytesToReceive)
            : base()
        {
            this.bytesReceived = bytesReceived;
            this.totalBytesToReceive = totalBytesToReceive;
            this.progressPercentage = (int)((((double)bytesReceived) / totalBytesToReceive) * 100);
        }
        #endregion

        #region Properties

        /// <summary>
        /// Gets the number of bytes received.
        /// </summary>
        /// <value>An <see cref="Int64"/> value that indicates the number of bytes received.</value>
        /// <remarks>To determine what percentage of the transfer has occurred, use the <see cref="ProgressPercentage"/> property.</remarks>
        public long BytesReceived
        {
            get
            {
                return this.bytesReceived;
            }
        }

        /// <summary>
        /// Gets the total number of bytes to be received. 
        /// </summary>
        /// <value>An <see cref="Int64"/> value that indicates the number of bytes that will be received.</value>
        /// <remarks>To determine the number of bytes already received, use the <see cref="BytesReceived"/> property.
        /// To determine what percentage of the transfer has occurred, use the <see cref="ProgressPercentage"/> property.
        /// </remarks>
        public long TotalBytesToReceive
        {
            get
            {
                return this.totalBytesToReceive;
            }
        }

        /// <summary>
        /// Gets the task progress percentage. 
        /// </summary>
        /// <value>A percentage value indicating the task progress.</value>
        /// <remarks>The <see cref="ProgressPercentage"/> property determines what percentage of a task has been completed.</remarks>
        public int ProgressPercentage
        {
            get
            {
                return this.progressPercentage;
            }
        }

        #endregion

    }
}
